package me.weijing.common.util;

import java.text.DecimalFormat;
public class StringUtil {
    /**
     * 数字格式化
     */
    private static final DecimalFormat df = new DecimalFormat("####.00");
    static {
        // 四舍五入
        /* df.setRoundingMode(RoundingMode.HALF_UP); */
    }

    /**
     * 距离格式化
     * 
     * @param distance
     * @return
     */
    public static String formatDistance(final int distance) {
        if (distance >= 1000) {
            return df.format(distance / 1000D) + "千米";
        }
        return distance + "米";
    }

}
